class Solution {
public:
    bool ispalindrome(string s)
    {
        int left = 0;
        int right = s.size() - 1;
        while (left < right)
        {
            if (s[left] != s[right])
            {
                return false;
            }
            left++;
            right--;
        }
        return true;
    }
    int getLongestPalindrome(string A) {
        int l = 0;
        int r = 0;
        int n = 0;
        while (l < A.size())
        {
            r = l;
            while (r < A.size())
            {
                string a = A.substr(l, (r - l + 1));
                if (ispalindrome(a))
                {
                    n = n > a.size() ? n : a.size();
                }
                r++;
            }
            l++;
        }
        return n;
    }
};